<template>
  <div class="communityContainer">
    <div class="community">
      <div class="left">
        <div class="chart" style="margin: 15px 0;font-size: 20px">
          可视化显示
        </div>
        <div style="color: rgb(83, 83, 83);font-size: 13px;margin: 15px 0;">
          <div style="margin: 15px 0;cursor: pointer;" @click="$router.push('/interviewEcharts')">
            岗位与薪资统计图
          </div>
          <div style="margin: 15px 0;cursor: pointer;" @click="$router.push('/interviewEcharts2')">
            招聘城市统计图
          </div>
        </div>


        <div class="sort">
          <div class="sortItem" @click="changePage(null)" style="color: #18365b;font-weight: 600;">
<!--              :class="$route.query.interType == null ? 'currentItem' : ''"-->
<!--              @click="changeType(null)"-->

            <p style="font-size: 20px">岗位类型</p>
          </div>
          <div
              class="sortItem"
              :class="$route.query.interType == item.typeId ? 'currentItem' : ''"
              v-for="(item, index) in interTypeList"
              :key="index"
              @click="changeType(item.typeId)">
            <i class="iconfont icon-biaoqian"></i>&nbsp;&nbsp;{{ item.typeName }}
          </div>
        </div>
      </div>
      <div class="right">
        <div class="inter" v-loading="isDataLoad">
          <div
              class="interItem"
              v-for="(item, index) in interviewList"
              :key="index"
              @click="$router.push({ name: 'interdetail', params: { id: item.interId } })">
            <div class="ItemCenter">
              <h3 class="title" style="margin: 0">
                {{ item.interCategory }}【{{item.interAddress}}】
                <span style="margin-left: 10px;"></span>
                <span style="color:#ff6400"> {{ item.interInfo }}</span>
              </h3>

              <div class="content mdContent" style="padding-top: 10px">
                【技能要求】
                {{ item.interTechnology.length > 120 ? item.interTechnology.substr(0, 300) : item.int }}...
              </div>
              <div class="mybottom" style="padding-top: 10px;color: rgb(136, 136, 136);font-size: 8px">
                <img :src="gongsi1" style="width: 20px;height: 20px;">
                {{ item.interTitle }}
                <span style="padding-left: 20px;"></span>
                <i class="iconfont icon-lishi"></i>
                {{ item.createTime | handleInterviewDateShow }}
              </div>
            </div>
            <div class="interImg">
              <img
                  v-if="item.interImage != ''"
                  :src="item.interImage"
                  class="interImgItem"
                  fit="contain"
                  lazy
              />
            </div>
          </div>
        </div>
        <div
            class="nullTips"
            v-if="interviewList.length == 0 && isDataLoad == false"
        >
          Interview Not Found !
        </div>

        <div class="bottom" v-if="!isDataLoad && interviewList.length !== 0">
          <!-- 分页组件 -->
          <el-pagination
              background
              layout="prev, pager, next"
              :total="totalCount"
              :current-page="this.$route.query.page * 1"
              @current-change="changePage"
          >
          </el-pagination>
        </div>
      </div>
    </div>
    <!-- 返回顶部组件 -->
    <go-top></go-top>
  </div>
</template>

<script>

import {handleInterviewDateShow} from "plugins/utils.js";
import GoTop from "components/goTop/GoTop.vue";

export default {
  name: "interview",
  components: {
    GoTop,
  },
  data() {
    return {
      // 文章数据
      interviewList: [],
      interTypeList: [],
      // 总条数
      totalCount: 0,
      interType: '',
      // 是否正在加载数据
      isDataLoad: true,
      gongsi1: require("assets/img/gongsi1.png"),
    };
  },
  methods: {
    // 请求
    async getAllInterview() {
      this.isDataLoad = true;
      let res = await this.$request("/dqinterview/superlist", {
        pageNum: this.$route.query.page,
        pageSize: 10,
      });
      console.log(res);
      if (res.data.code == 200) {
        this.totalCount = res.data.data.total;
        this.interviewList = res.data.data.list;
        this.isDataLoad = false;
        // 返回顶部
        window.scrollTo({
          top: 0,
          behavior: "smooth",
        });
      }
    },
    async getAllInterviewByType(interType) {
      this.isDataLoad = true;
      let res = await this.$request(`/dqinterview/superlist?interType=${interType}`, {
        pageNum: this.$route.query.page,
        pageSize: 10,
      });
      console.log(res);
      if (res.data.code == 200) {
        this.totalCount = res.data.data.total;
        this.interviewList = res.data.data.list;
        this.isDataLoad = false;
        // 返回顶部
        window.scrollTo({
          top: 0,
          behavior: "smooth",
        });
      }
    },

    changeType(interType) {
      if (this.$route.query.interType == interType) return;
      this.$router.push({name: "interview", query: {interType: interType, page: 1}});
      if (interType == null || interType == '') {
        // 查询全部文章
        this.getAllInterview();
      } else {
        this.getAllInterviewByType(interType);
      }
    },

    // 切换分页的回调
    changePage(e) {
      // console.log(e);
      // this.currentPage = e;
      this.$router.push({
        name: "interview",
        query: {page: e},
      });
      this.getAllInterview();

    },
    async getInterTypeList() {
      let res = await this.$request("/dqinterviewType/list");
      console.log(res.data.data);
      this.interTypeList = res.data.data;
    },
  },
  computed: {},
  filters: {
    handleInterviewDateShow,
  },
  created() {
    // 查询文章列表数据
    this.getAllInterview('');
    this.getInterTypeList();
  },
  goCurrentPage(path) {
    if (this.$route.fullPath != path) {
      this.$router.push(path);
      // 回到顶部
      window.scrollTo(0, 0);
    }
  },
};
</script>

<style scoped>
.mybottom {
  display: inline-block;
}

.communityContainer {
  display: flex;
  justify-content: center;
  font-size: 15px;
}

.community {
  display: flex;
  max-width: 1200px;
  width: 85vw;
}


.right {
  padding: 10px 20px 20px;
  width: calc(100%);
}

.interItem {
  display: flex;
  position: relative;
  border-bottom: 5px solid #eee;
  padding: 20px 20px 20px;
  cursor: pointer;
  border-radius: 5px;
  transition: all 0.15s;
  margin-left: 80px;
}

.interItem:hover {
  background-color: #f2f6fb;
}

.userAvatar {
  width: 45px;
}

.userAvatar img {
  height: 40px;
  width: 40px;
  border-radius: 50%;
}

.ItemCenter {
  width: 770px;
  margin: 0 10px;
}

.ItemCenter div {
  margin-bottom: 1px;
  line-height: 18px;
}
.chart{
  color: #18365b;
  font-weight: 600;
}

.title {
  font-size: 18px;
  font-weight: bold;
  line-height: 25px;
  color: rgb(43, 43, 43);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.publishDate {
  color: rgb(136, 136, 136);
  margin: 4px 0;
  font-size: 12px;
}

.content {
  color: rgb(136, 136, 136);
  font-size: 14px;
  line-height: 19px;
  /* 两行溢出 */
  text-overflow: ellipsis;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  -webkit-box-orient: vertical;
}

.interImg {
  margin: 15px 0 10px;
  display: flex;
  justify-content: flex-start;
}

.interImg img {
  border-radius: 5px;
}

.interImgItem {
  height: 100px;
  width: auto;
  margin-right: 10px;
}

.interImgItem /deep/ .el-image__inner {
  width: unset;
}

.bottom {
  width: 100%;
  text-align: center;
  margin: 40px 0;
}

.communityContainer /deep/ .el-loading-spinner {
  margin-top: 80px;
}

.nullTips {
  text-align: center;
  margin-top: 20vh;
  color: #666;
  letter-spacing: 1px;
}
.left {
  position: sticky;
  top: 74px;
  padding: 20px 0;
  width: 200px;
  /* 74px+padding上下的20px */
  height: calc(100vh - 114px);
  color: rgb(83, 83, 83);
  font-size: 13px;
}
.sortItem {
  margin: 15px 0;
  cursor: pointer;
}
.sort{
  margin-top: 50px;
}

.currentItem {
  color: #18365b;
  font-weight: 600;
}
</style>
